define(['dojo/_base/declare'], function(declare) {
	'use strict';

	return declare(null, {
		constructor: function(mapDOM, containerDom, map) {
			this.html =
				'<div>' +				
					'<div class="layui-tab" lay-filter="prediction-tab">' +
						'<ul class="layui-tab-title" id="prediction-Tab">' +
						'<li class="active"> <a href="#prediction-signal" data-toggle="tab">预警信号</a></li>' +
						'<li><a href="#prediction-warning" data-toggle="tab">预警</a></li>' +
						'</ul >' +
						'<div class="layui-tab-content">' +
							'<div class="layui-tab-item layui-show" id="prediction-signal"><div><table class="layui-hide" id="prediction-signalTable"></table></div></div>' +
							'<div class="layui-tab-item" id="prediction-warning"><div><table class="layui-hide" id="prediction-warningTable"></table></div></div>' +
						'</div >' +
					'</div>' +
					'<button class="layui-btn layui-btn-primary layui-btn-fluid" id="prediction-more" style="float:left;bottom:0;"><i class="layui-icon" style="color: #1E9FFF;">&#xe61a;</i>更多</button>' +
				'</div>' +
				//'</div>' +
				'<div class="modal fade" id="myModal">' +
					'<div class="modal-dialog" style="width:940px;">' +
						'<div class="modal-content">' +
							' <!-- 模态框头部 -->' +
							'<div class="modal-header">' +
								'<h5 class="modal-title">预警详情</h5>' +
								'<button type="button" class="close" data-dismiss="modal">&times;</button>' +
							'</div>' +
						'<!-- 模态框主体 -->' +
							'<div class="modal-body" id="preview-msg">' +
								'<div class="lightbox"></div>' +
								'<div id="pop" class="pop">' +
								'<canvas id="the-canvas"></canvas>' +
							'</div>' +
						'</div>' +
						'<!-- 模态框底部 -->' +
						'<div class="modal-footer">' +
							'<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>' +
						'</div>' +
					'</div>' +
				'</div>';

			this.moreHtml =
				'<div class="row">' +
				'<div class="col-sm-4">' +
				'<select class="form-control" id="prediction-station">' +
				'<option value="" > 请选择发布单位</option>' +
				'</select>' +
				'</div>' +
				'<div class="col-sm-4">' +
				'<select class="form-control" id="prediction-type" title="灾害类型">' +
				'<option value="" > 请选择灾害类型</option>' +
				'</select>' +
				'</div>' +
				'<div class="col-sm-4">' +
				'<select class="form-control" id="prediction-level" title="灾害等级">' +
				'<option value="" > 请选择灾害等级</option>' +
				'</select>' +
				'</div>' +
				'</div>' +
				'<div class="row">' +
				'<div class="col-sm-4">' +
				'<select class="form-control" id="prediction-status" title="灾害状态">' +
				'<option value=""> 请选择灾害状态</option>' +
				'</select>' +
				'</div>' +
				'<div class="col-sm-4">' +
				'<input type="text" class="layui-input" id="times" placeholder="请选择查询时间段"/>' +
				'</div>' +
				'<div class="col-sm-1 col-sm-offset-2">' +
				'<button class="btn btn-info" id="prediction-search" type="button">查询</button>' +
				'</div>' +
				'</div>' +
				'<div class="row">' +
				'<div class="table-responsive" id="prediction-moreDetails"></div>' +
				'</div>';
			this.$map = null;
			this.isShown = false;
			this.signalTableId = "prediction-signalTable";
			this.warningTableId = "prediction-warningTable";
			this.currentTab = "prediction-signal";
			this.loaded = false;
			this.map = null;
			this.urlList = {
				getLatestEws: "http://61.157.118.158:8088/sndm/api/ThreeLevelMspAction/getEwsNewestSub",
				getEws: "http://61.157.118.158:8088/sndm/api/ThreeLevelMspAction/getEwsOrDwNewest?type=0",
				getDws: "http://61.157.118.158:8088/sndm/api/ThreeLevelMspAction/getEwsOrDwNewest?type=1",
				getMoreEws: "http://61.157.118.158:8088/sndm/api/ThreeLevelMspAction/getEwsOrDwAll?type=0",
				getMoreDws: "http://61.157.118.158:8088/sndm/api/ThreeLevelMspAction/getEwsOrDwAll?type=1"
			};
			this.station = [{
					"U_ID": "bccd.bfsn.qxt",
					"NAME": "遂宁市气象台",
					"X": 105.54923917122281,
					"Y": 30.53769573537072
				},
				{
					"U_ID": "bccd.bfsn.nq",
					"NAME": "遂宁市农气中心",
					"X": 105.57573673719526,
					"Y": 30.507530000094366
				},
				{
					"U_ID": "bccd.bfsn.srv",
					"NAME": "遂宁市科技服务中心",
					"X": 105.56431760880324,
					"Y": 30.527894615267005
				},
				{
					"U_ID": "bccd.bfsn.ryb",
					"NAME": "遂宁市人影办",
					"X": 105.54921316738182,
					"Y": 30.53782194624301
				},
				{
					"U_ID": "bccd.bfsn.fl",
					"NAME": "遂宁市防雷中心",
					"X": 105.5491641862383,
					"Y": 30.538087341375135
				},
				{
					"U_ID": "bccd.bfsn.bxsh",
					"NAME": "射洪县气象局",
					"X": 105.37698776974588,
					"Y": 30.87296073126909
				},
				{
					"U_ID": "bccd.bfsn.bxpe",
					"NAME": "蓬溪县气象局",
					"X": 105.7047885130283,
					"Y": 30.773016391470684
				},
				{
					"U_ID": "bccd.bfsn.bxda",
					"NAME": "大英县气象局",
					"X": 105.24306324203664,
					"Y": 30.583066521777
				}
			];
			this.signalClass = {
				type: [{
						"NAME": "暴雨",
						"P_ID": "WARN_BY"
					},
					{
						"NAME": "大风",
						"P_ID": "WARN_DF"
					},
					{
						"NAME": "雷电",
						"P_ID": "WARN_LD"
					},
					{
						"NAME": "高温",
						"P_ID": "WARN_GW"
					},
					{
						"NAME": "干旱",
						"P_ID": "WARN_GH"
					},
					{
						"NAME": "大雾",
						"P_ID": "WARN_DW"
					},
					{
						"NAME": "寒潮",
						"P_ID": "WARN_HC"
					},
					{
						"NAME": "冰雹",
						"P_ID": "WARN_BB"
					},
					{
						"NAME": "暴雪",
						"P_ID": "WARN_BX"
					},
					{
						"NAME": "霜冻",
						"P_ID": "WARN_SD"
					},
					{
						"NAME": "沙尘暴",
						"P_ID": "WARN_SB"
					},
					{
						"NAME": "霾",
						"P_ID": "WARN_MA"
					},
					{
						"NAME": "道路结冰",
						"P_ID": "WARN_DB"
					},
					{
						"NAME": "森林/草原火险",
						"P_ID": "WARN_HX"
					}
				],
				level: [{
						"NAME": "红色",
						"P_ID": "WARN_%_RD",
						"Reg": "/WARN_(\\S*?)_RD/",
						"Regx": /WARN_(\S*?)_RD/
					},
					{
						"NAME": "橙色",
						"P_ID": "WARN_%_OR",
						"Reg": "/WARN_(\\S*?)_OR/",
						"Regx": /WARN_(\S*?)_OR/
					},
					{
						"NAME": "黄色",
						"P_ID": "WARN_%_YE",
						"Reg": "/WARN_(\\S*?)_YE/",
						"Regx": /WARN_(\S*?)_YE/
					},
					{
						"NAME": "蓝色",
						"P_ID": "WARN_%_BL",
						"Reg": "/WARN_(\\S*?)_BL/",
						"Regx": /WARN_(\S*?)_BL/
					}
				],
				status: [{
						"NAME": "发布",
						"P_ID": "WARN_%_FB"
					},
					{
						"NAME": "更新",
						"P_ID": "WARN_%_GX"
					},
					{
						"NAME": "确认",
						"P_ID": "WARN_%_QR"
					},
					{
						"NAME": "解除",
						"P_ID": "WARN_%_JC"
					}
				]
			};
			this.warningClass = {
				type: [{
						"NAME": "干旱",
						"P_ID": "ALRM_GH"
					},
					{
						"NAME": "暴雨",
						"P_ID": "ALRM_BY"
					},
					{
						"NAME": "大风",
						"P_ID": "ALRM_DF"
					},
					{
						"NAME": "高温",
						"P_ID": "ALRM_GW"
					},
					{
						"NAME": "低温",
						"P_ID": "ALRM_DW"
					},
					{
						"NAME": "大雾",
						"P_ID": "ALRM_DW"
					},
					{
						"NAME": "寒潮",
						"P_ID": "ALRM_HC"
					},
					{
						"NAME": "暴雪",
						"P_ID": "ALRM_BX"
					},
					{
						"NAME": "霜冻",
						"P_ID": "ALRM_SD"
					},
					{
						"NAME": "冰冻",
						"P_ID": "ALRM_BD"
					},
					{
						"NAME": "霾",
						"P_ID": "ALRM_MA"
					}
				],
				level: [{
						"NAME": "红色",
						"P_ID": "ALRM_%_RD",
						"Reg": "/ALRM_(\\S*?)_RD/",
						"Regx": /ALRM_(\S*?)_RD/
					},
					{
						"NAME": "橙色",
						"P_ID": "ALRM_%_OR",
						"Reg": "/ALRM_(\\S*?)_OR/",
						"Regx": /ALRM_(\S*?)_OR/
					},
					{
						"NAME": "黄色",
						"P_ID": "ALRM_%_YE",
						"Reg": "/ALRM_(\\S*?)_YE/",
						"Regx": /ALRM_(\S*?)_YE/
					},
					{
						"NAME": "蓝色",
						"P_ID": "ALRM_%_BL",
						"Reg": "/ALRM_(\\S*?)_BL/",
						"Regx": /ALRM_(\S*?)_BL/
					}
				],
				status: [{
						"NAME": "发布",
						"P_ID": "ALRM_%_FB"
					},
					{
						"NAME": "更新",
						"P_ID": "ALRM_%_GX"
					},
					{
						"NAME": "确认",
						"P_ID": "ALRM_%_QR"
					},
					{
						"NAME": "解除",
						"P_ID": "ALRM_%_JC"
					}
				]
			};
			this.startDate = '';
			this.endDate = '';
			this.layui_table = '';
			//this.show(mapDOM,containerDom,map);
		},

		show: function(mapDOM, containerDom, map) {
			layui.config({
				dir: '../js/dep/layui/' //layui.js 所在路径（注意，如果是script单独引入layui.js，无需设定该参数。），一般情况下可以无视
			});
			this.$map = $("#" + mapDOM);
			this.map = map;
			var curInstance = this;
			$(containerDom).append(curInstance.html);
			layui.use(['table','element'], function() {				
				var element = layui.element;
				var table = layui.table;
				curInstance.layui_table = table;
				
				$("#prediction-Show").on("click", function() {
					curInstance.isShown = !curInstance.isShown;
					if(curInstance.isShown) {
						$(".prediction").slideDown();
					} else {
						$(".prediction").slideUp();
					}
				});
				//切换tab
				element.on('tab(prediction-tab)', function(data){
					if(data.index===0) {
						curInstance.currentTab=curInstance.signalTableId;
						curInstance.createSignalTable(curInstance.urlList.getLatestEws, curInstance);
					} else if(data.index===1) {
						curInstance.currentTab=curInstance.warningTableId;
						curInstance.createWarningTable(curInstance.urlList.getDws, curInstance);
					}
				});
				
				$("#prediction-Tab li").on("click", function(event) {
					curInstance.currentTab = event.target.hash.replace("#", "");
					if(event.target.hash === "#prediction-signal") {
						curInstance.createSignalTable(curInstance.urlList.getLatestEws, curInstance);
					} else {
						curInstance.createWarningTable(curInstance.urlList.getDws, curInstance);
					}
				});

				$("#prediction-more").click(function() {
					layui.use(['layer', 'laydate'], function() {
						var layer = layui.layer,
							laydate = layui.laydate;
						layer.open({
							id: 'prediction-history',
							title: '更多',
							content: curInstance.moreHtml,
							area: '800px',
							offset: '2px',
							zIndex: 999
						});
						laydate.render({
							elem: '#times',
							type: 'datetime',
							range: true,
							done: function(value, date, endDate) {
								curInstance.startDate = date.year.toString() +
									date.month.toString().padLeft(2, "0") +
									date.date.toString().padLeft(2, "0") +
									date.hours.toString().padLeft(2, "0") +
									date.minutes.toString().padLeft(2, "0") +
									date.seconds.toString().padLeft(2, "0");
								curInstance.endDate = endDate.year.toString() +
									endDate.month.toString().padLeft(2, "0") +
									endDate.date.toString().padLeft(2, "0") +
									endDate.hours.toString().padLeft(2, "0") +
									endDate.minutes.toString().padLeft(2, "0") +
									endDate.seconds.toString().padLeft(2, "0");
							},
						});
						if(curInstance.currentTab == "prediction-signal") {
							curInstance.createSignalMore(curInstance.urlList.getMoreEws, curInstance, {
								tableId: "prediction-moreDetails"
							});
						} else {
							curInstance.createWarningMore(curInstance.urlList.getDws, curInstance, {
								tableId: "prediction-moreDetails"
							});
						}
						//});
					});
				});

				//展示已知数据
				table.render({
					//id: this.signalTableId,
					elem: '#' + this.signalTableId,
					cols: [
						[{
								field: 'DESCRIPTION',
								title: '产品标题',
								sort: true
							},
							{
								field: 'P_TIME',
								title: '发布时间',
								sort: true
							},
							{
								field: 'P_USER',
								title: '发布单位',
								sort: true
							},
							{
								field: 'FILE_DOC',
								visible: false
							},
							{
								field: 'FILE_PDF',
								visible: false
							},
							{
								field: 'X',
								visible: false
							},
							{
								field: 'Y',
								visible: false
							}
						]
					],
					data: [],
					//skin: 'line', //表格风格
					even: true,
					page: true, //是否显示分页
					limits: [5, 7, 10],
					limit: 5, //每页默认显示的数量
					done:function(res,curr,count){
						$("[data-field='X']").css('display','none');
						$("[data-field='Y']").css('display','none');						
					}					
				});
				
				table.render({
					//id: this.warningTableId,
					elem: '#' + this.warningTableId,
					cols: [
						[ //标题栏
							{
								field: 'DESCRIPTION',
								title: '产品标题',
								sort: true
							},
							{
								field: 'P_TIME',
								title: '发布时间',
								sort: true
							},
							{
								field: 'P_USER',
								title: '发布单位',
								sort: true
							},
							{
								field: 'FILE_DOC',
								visible: false
							},
							{
								field: 'FILE_PDF',
								visible: false
							},
							{
								field: 'X',
								visible: false
							},
							{
								field: 'Y',
								visible: false
							}
						]
					],
					data: [{
							ISSUE: "2018年第0006期",
							DESCRIPTION: "大英县发布雷电黄色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_LD_YE_FB_BXDA_20180316211500_20180006.docx&fileType=ews_file_doc&fileTime=20180316",
							P_NAME: "雷电黄色预警信号发布单",
							P_TIME: "2018-03-16 21:15:00",
							P_USER: "大英县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_LD_YE_FB_BXDA_20180316211500_20180006.pdf&fileType=ews_file_pdf&fileTime=20180316"
						},
						{
							ISSUE: "2018年第0007期",
							DESCRIPTION: "射洪县发布大风蓝色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXSH_20180304130900_20180007.docx&fileType=ews_file_doc&fileTime=20180304",
							P_NAME: "大风蓝色预警信号发布单",
							P_TIME: "2018-03-04 13:09:00",
							P_USER: "射洪县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXSH_20180304130900_20180007.pdf&fileType=ews_file_pdf&fileTime=20180304"
						},
						{
							ISSUE: "2018年第0005期",
							DESCRIPTION: "大英县发布大风蓝色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXDA_20180304125900_20180005.docx&fileType=ews_file_doc&fileTime=20180304",
							P_NAME: "大风蓝色预警信号发布单",
							P_TIME: "2018-03-04 12:59:00",
							P_USER: "大英县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXDA_20180304125900_20180005.pdf&fileType=ews_file_pdf&fileTime=20180304"
						},
						{
							ISSUE: "2018年第0007期",
							DESCRIPTION: "蓬溪县发布大风蓝色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXPE_20180304121200_20180007.docx&fileType=ews_file_doc&fileTime=20180304",
							P_NAME: "大风蓝色预警信号发布单",
							P_TIME: "2018-03-04 12:12:00",
							P_USER: "蓬溪县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXPE_20180304121200_20180007.pdf&fileType=ews_file_pdf&fileTime=20180304"
						},
						{
							ISSUE: "2018年第0007期",
							DESCRIPTION: "遂宁市发布大风蓝色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BFSN_20180304114500_20180007.docx&fileType=ews_file_doc&fileTime=20180304",
							P_NAME: "大风蓝色预警信号发布单",
							P_TIME: "2018-03-04 11:45:00",
							P_USER: "遂宁市气象台",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BFSN_20180304114500_20180007.pdf&fileType=ews_file_pdf&fileTime=20180304"
						},
						{
							ISSUE: "2018年第0006期",
							DESCRIPTION: "射洪县发布大雾黄色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXSH_20180216075500_20180006.docx&fileType=ews_file_doc&fileTime=20180216",
							P_NAME: "大雾黄色预警信号发布单",
							P_TIME: "2018-02-16 07:55:00",
							P_USER: "射洪县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXSH_20180216075500_20180006.pdf&fileType=ews_file_pdf&fileTime=20180216"
						},
						{
							ISSUE: "2018年第0006期",
							DESCRIPTION: "遂宁市发布大雾黄色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BFSN_20180216074500_20180006.docx&fileType=ews_file_doc&fileTime=20180216",
							P_NAME: "大雾黄色预警信号发布单",
							P_TIME: "2018-02-16 07:45:00",
							P_USER: "遂宁市气象台",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BFSN_20180216074500_20180006.pdf&fileType=ews_file_pdf&fileTime=20180216"
						},
						{
							ISSUE: "2018年第0006期",
							DESCRIPTION: "蓬溪县发布大雾黄色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXPE_20180216074100_20180006.docx&fileType=ews_file_doc&fileTime=20180216",
							P_NAME: "大雾黄色预警信号发布单",
							P_TIME: "2018-02-16 07:41:00",
							P_USER: "蓬溪县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXPE_20180216074100_20180006.pdf&fileType=ews_file_pdf&fileTime=20180216"
						}
					],
					//skin: 'line', //表格风格
					even: true,
					page: true, //是否显示分页
					limits: [5, 7, 10],
					limit: 5, //每页默认显示的数量
					done:function(res,curr,count){
						$("[data-field='X']").css('display','none');
						$("[data-field='Y']").css('display','none');						
					}
				});
				$('#' + curInstance.signalTableId).on('click-row.bs.table', function(e, rows) {
					//layui_layer.open({
					//    type: 1,
					//    id: 'prediction-preview', //设定一个id，防止重复弹出
					//    title: false, //不显示标题栏
					//    closeBtn: true,
					//    area: ['50%','2000px;'],
					//    shade: 0.8,
					//    offset: '2px',
					//    //scrollbar: true,
					//    fix: true,
					//    content: predictObj.previewHtml,
					//    success: function () {
					//        predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
					//    }                                
					//});
					$('#myModal').on('show.bs.modal', function() { //61.157.118.158:8088
						curInstance.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
					});
					$('#myModal').modal('show');
				});

				$('#' + curInstance.warningTableId).on('click-row.bs.table', function(e, rows) {
					//layui_layer.open({
					//    type: 1,
					//    id: 'prediction-preview', //设定一个id，防止重复弹出
					//    title: false, //不显示标题栏
					//    closeBtn: true,
					//    area: ['50%','2000px;'],
					//    shade: 0.8,
					//    offset: '2px',
					//    //scrollbar: true,
					//    fix: true,
					//    content: predictObj.previewHtml,
					//    success: function () {
					//        predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
					//    }                                
					//});
					$('#myModal').on('show.bs.modal', function() { //61.157.118.158:8088
						curInstance.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
					});
					$('#myModal').modal('show');
				});

				curInstance.createSignalTable(curInstance.urlList.getLatestEws, curInstance);
				//this.addBorder(curInstance);
				padLeft();
			});
		},

		createSignalMore: function(url, predictObj, options) {
			//绑定下拉列表
			for(var i = 0; i < predictObj.station.length; i++) {
				var option = "<option id='" + predictObj.station[i].NAME + "'>" + predictObj.station[i].NAME + "</option>";
				$("#prediction-station").append(option);
			}
			$.each(predictObj.signalClass, function(key, value) {
				for(var i in value) {
					var option = "<option id='" + value[i].NAME + "'>" + value[i].NAME + "</option>";
					$("#prediction-" + key).append(option);
				}
			});
			options = options || {};
			var $tableId = options.tableId || predictObj.warningTableId;
			$.ajax({
				url: url,
				type: 'GET',
				success: function(data) {
					//options = options || {};
					//var $tableId = options.tableId || prediction.warningTableId;
					var productClass = predictObj.signalClass;

					var tableData = data; //warningData;
					//2.加载产品列表
//					var $table = $("#" + $tableId);
//					var child = $table.children();
//					if(child.length > 0) {
//						child.remove();
//					}
					//                      $table.bootstrapTable({
					//                          data: tableData,
					//                          striped: true,                       //是否显示行间隔色
					//                          pagination: true,                    //是否显示分页（*）   
					//                          //search: true,                        //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
					//                          pageSize: 4,                         //每页的记录行数（*）
					//                          //pageList: [5, 25, 50, 100],        //可供选择的每页的行数（*）
					//                          sidePagination: "client",
					//                          //showColumns: true,                 //是否显示所有的列
					//                          //showRefresh: true,                 //是否显示刷新按钮
					//                          //showToggle: true,                  //是否显示详细视图和列表视图的切换按钮
					//                          //cardView: false,                   //是否显示详细视图
					//                          //detailView: false,                 //是否显示父子表                                
					//                          locale: "zh-CN",                     //默认英文，设置如下就是显示中文                                
					//                          columns: [{
					//                              field: 'DESCRIPTION',
					//                              title: '产品标题',
					//                              sortable: true,
					//                              width: '60%',
					//                          },
					//                          {
					//                              field: 'P_TIME',
					//                              title: '发布时间',
					//                              sortable: true,
					//                              width: '30%',
					//                          },
					//                          {
					//                              field: 'P_USER',
					//                              title: '发布单位',
					//                              sortable: true,
					//                              width: '30%',
					//                          },
					//                          {
					//                              field: 'FILE_DOC',
					//                              visible: false
					//                          },
					//                          {
					//                              field: 'FILE_PDF',
					//                              visible: false
					//                          }],
					//                          rowStyle: function (row, index) {
					//                              //这里有5个取值代表5中颜色['active', 'success', 'info', 'warning', 'danger'];
					//                              var strclass = "active";
					//                              return { classes: strclass }
					//                          },
					//                          //uniqueId: "usrId",
					//                          clickToSelect: true,                 //是否启用点击选中行
					//                          maintainSelected: true,           //设置为 true 在点击分页按钮或搜索按钮时，将记住checkbox的选择项
					//                          //responseHandler: responseHandler, //在渲染页面数据之前执行的方法，此配置很重要!!!!!!!  
					//                      });
					//                      //绑定选中事件、取消事件、全部选中、全部取消  
					//                      $table.on('click-row.bs.table', function (e, rows) {
					//                          //layui_layer.open({
					//                          //    type: 1,
					//                          //    id: 'prediction-preview', //设定一个id，防止重复弹出
					//                          //    title: false, //不显示标题栏
					//                          //    closeBtn: true,
					//                          //    area: ['50%','2000px;'],
					//                          //    shade: 0.8,
					//                          //    offset: '2px',
					//                          //    //scrollbar: true,
					//                          //    fix: true,
					//                          //    content: predictObj.previewHtml,
					//                          //    success: function () {
					//                          //        predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
					//                          //    }                                
					//                          //});
					//                          $('#myModal').on('show.bs.modal', function () {//61.157.118.158:8088
					//                              predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
					//                          });
					//                          $('#myModal').modal('show');
					//                      });
					//                  
				},
				error: function() {}
			});
			$("#prediction-search").on("click", function() {
				var dic = $("#prediction-station")[0].selectedIndex === 0 ? "&dic=" : "&dic=" + $("#prediction-station")[0].options[$("#prediction-station")[0].selectedIndex].innerHTML;
				var byDisasterType = $("#prediction-type")[0].selectedIndex === 0 ? "&byDisasterType=" : "&byDisasterType=" + $("#prediction-type")[0].options[$("#prediction-type")[0].selectedIndex].innerHTML;
				var ByLevle = $("#prediction-level")[0].selectedIndex === 0 ? "&ByLevle=" : "&ByLevle=" + $("#prediction-level")[0].options[$("#prediction-level")[0].selectedIndex].innerHTML;
				var ByState = $("#prediction-status")[0].selectedIndex === 0 ? "&ByState=" : "&ByState=" + $("#prediction-status")[0].options[$("#prediction-status")[0].selectedIndex].innerHTML;
				var times = predictObj.startDate === '' ? "&times=" : "&times=" + predictObj.startDate + "," + predictObj.endDate; //$("#prediction-status").options[$("#prediction-station").selectedIndex];
				var newUrl = url + dic + byDisasterType + ByLevle + ByState + times;
				$.ajax({
					url: newUrl,
					type: 'GET',
					success: function(data) {
						$("#" + $tableId).bootstrapTable('load', data);
						predictObj.startDate = '';
						predictObj.endDate = '';
					},
					error: function() {}
				});

			});
		},

		createWarningMore: function(url, predictObj, options) {
			//绑定下拉列表
			for(var i = 0; i < predictObj.station.length; i++) {
				var option = "<option id='" + predictObj.station[i].NAME + "'>" + predictObj.station[i].NAME + "</option>";
				$("#prediction-station").append(option);
			}
			$.each(predictObj.warningClass, function(key, value) {
				for(var i in value) {
					var option = "<option id='" + value[i].NAME + "'>" + value[i].NAME + "</option>";
					$("#prediction-" + key).append(option);
				}
			});
			options = options || {};
			var $tableId = options.tableId || predictObj.warningTableId;
			$.ajax({
				url: url,
				type: 'GET',
				success: function(data) {
					//options = options || {};
					//var $tableId = options.tableId || predictObj.warningTableId;
					var productClass = predictObj.warningClass;

					var tableData = data; //warningData;
					//2.加载产品列表
//					var $table = $("#" + $tableId);
//					var child = $table.children();
//					if(child.length > 0) {
//						child.remove();
//					}
					//                  $table.bootstrapTable({
					//                      data: tableData,
					//                      striped: true,                       //是否显示行间隔色
					//                      pagination: true,                    //是否显示分页（*）                                
					//                      //search: true,                        //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大                                                           
					//                      pageSize: 4,                         //每页的记录行数（*）
					//                      //pageList: [5, 25, 50, 100],        //可供选择的每页的行数（*）
					//                      sidePagination: "client",
					//                      //showColumns: true,                 //是否显示所有的列
					//                      //showRefresh: true,                 //是否显示刷新按钮
					//                      //showToggle: true,                  //是否显示详细视图和列表视图的切换按钮
					//                      //cardView: false,                   //是否显示详细视图
					//                      //detailView: false,                 //是否显示父子表                                
					//                      locale: "zh-CN",                     //默认英文，设置如下就是显示中文                                
					//                      columns: [{
					//                          field: 'DESCRIPTION',
					//                          title: '产品标题',
					//                          sortable: true,
					//                          width: '60%',
					//                      },
					//                      {
					//                          field: 'P_TIME',
					//                          title: '发布时间',
					//                          sortable: true,
					//                          width: '30%',
					//                      },
					//                      {
					//                          field: 'P_USER',
					//                          title: '发布单位',
					//                          sortable: true,
					//                          width: '30%',
					//                      },
					//                      {
					//                          field: 'FILE_DOC',
					//                          visible: false
					//                      },
					//                      {
					//                          field: 'FILE_PDF',
					//                          visible: false
					//                      }],
					//                      rowStyle: function (row, index) {
					//                          //这里有5个取值代表5中颜色['active', 'success', 'info', 'warning', 'danger'];
					//                          var strclass = "active";
					//                          return { classes: strclass }
					//                      },
					//                      //uniqueId: "usrId",
					//                      clickToSelect: true,                 //是否启用点击选中行
					//                      maintainSelected: true,           //设置为 true 在点击分页按钮或搜索按钮时，将记住checkbox的选择项
					//                      //responseHandler: responseHandler, //在渲染页面数据之前执行的方法，此配置很重要!!!!!!!  
					//                  });
					//                  //绑定选中事件、取消事件、全部选中、全部取消  
					//                  $table.on('click-row.bs.table', function (e, rows) {                            
					//                      $('#myModal').on('show.bs.modal', function () {//61.157.118.158:8088
					//                          predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
					//                      });
					//                      $('#myModal').modal('show');
					//                  });
					//              
				},
				error: function() {}
			});
			$("#prediction-search").on("click", function() {
				var dic = $("#prediction-station")[0].selectedIndex === 0 ? "&dic=" : "&dic=" + $("#prediction-station")[0].options[$("#prediction-station")[0].selectedIndex].innerHTML;
				var byDisasterType = $("#prediction-type")[0].selectedIndex === 0 ? "&byDisasterType=" : "&byDisasterType=" + $("#prediction-type")[0].options[$("#prediction-type")[0].selectedIndex].innerHTML;
				var ByLevle = $("#prediction-level")[0].selectedIndex === 0 ? "&ByLevle=" : "&ByLevle=" + $("#prediction-level")[0].options[$("#prediction-level")[0].selectedIndex].innerHTML;
				var ByState = $("#prediction-status")[0].selectedIndex === 0 ? "&ByState=" : "&ByState=" + $("#prediction-status")[0].options[$("#prediction-status")[0].selectedIndex].innerHTML;
				var times = predictObj.startDate === '' ? "&times=" : "&times=" + predictObj.startDate + "," + predictObj.endDate; //$("#prediction-status").options[$("#prediction-station").selectedIndex];
				var newUrl = url + dic + byDisasterType + ByLevle + ByState + times;
				$.ajax({
					url: newUrl,
					type: 'GET',
					success: function(data) {
						$("#" + $tableId).bootstrapTable('load', data);
						predictObj.startDate = '';
						predictObj.endDate = '';
					},
					error: function() {}
				});
			});
		},

		//获取最新预警信号列表并初始化表格
		createSignalTable: function(url, predictObj, options) {
			$.ajax({
				url: url,
				type: 'GET',
				success: function(data) {
					options = options || {};
					var $tableId = options.tableId || predictObj.signalTableId;
					var isShowLayer = options.showLayer || true;
					var layerNameSuffix = "_信号";
					var productClass = predictObj.signalClass;
					var tableData = [];
					data = [{
							ISSUE: "2018年第0006期",
							DESCRIPTION: "大英县发布雷电黄色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_LD_YE_FB_BXDA_20180316211500_20180006.docx&fileType=ews_file_doc&fileTime=20180316",
							P_NAME: "雷电黄色预警信号发布单",
							P_TIME: "2018-03-16 21:15:00",
							P_USER: "大英县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_LD_YE_FB_BXDA_20180316211500_20180006.pdf&fileType=ews_file_pdf&fileTime=20180316"
						},
						{
							ISSUE: "2018年第0007期",
							DESCRIPTION: "射洪县发布大风蓝色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXSH_20180304130900_20180007.docx&fileType=ews_file_doc&fileTime=20180304",
							P_NAME: "大风蓝色预警信号发布单",
							P_TIME: "2018-03-04 13:09:00",
							P_USER: "射洪县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXSH_20180304130900_20180007.pdf&fileType=ews_file_pdf&fileTime=20180304"
						},
						{
							ISSUE: "2018年第0005期",
							DESCRIPTION: "大英县发布大风蓝色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXDA_20180304125900_20180005.docx&fileType=ews_file_doc&fileTime=20180304",
							P_NAME: "大风蓝色预警信号发布单",
							P_TIME: "2018-03-04 12:59:00",
							P_USER: "大英县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXDA_20180304125900_20180005.pdf&fileType=ews_file_pdf&fileTime=20180304"
						},
						{
							ISSUE: "2018年第0007期",
							DESCRIPTION: "蓬溪县发布大风蓝色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXPE_20180304121200_20180007.docx&fileType=ews_file_doc&fileTime=20180304",
							P_NAME: "大风蓝色预警信号发布单",
							P_TIME: "2018-03-04 12:12:00",
							P_USER: "蓬溪县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BXPE_20180304121200_20180007.pdf&fileType=ews_file_pdf&fileTime=20180304"
						},
						{
							ISSUE: "2018年第0007期",
							DESCRIPTION: "遂宁市发布大风蓝色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BFSN_20180304114500_20180007.docx&fileType=ews_file_doc&fileTime=20180304",
							P_NAME: "大风蓝色预警信号发布单",
							P_TIME: "2018-03-04 11:45:00",
							P_USER: "遂宁市气象台",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DF_BL_FB_BFSN_20180304114500_20180007.pdf&fileType=ews_file_pdf&fileTime=20180304"
						},
						{
							ISSUE: "2018年第0006期",
							DESCRIPTION: "射洪县发布大雾黄色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXSH_20180216075500_20180006.docx&fileType=ews_file_doc&fileTime=20180216",
							P_NAME: "大雾黄色预警信号发布单",
							P_TIME: "2018-02-16 07:55:00",
							P_USER: "射洪县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXSH_20180216075500_20180006.pdf&fileType=ews_file_pdf&fileTime=20180216"
						},
						{
							ISSUE: "2018年第0006期",
							DESCRIPTION: "遂宁市发布大雾黄色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BFSN_20180216074500_20180006.docx&fileType=ews_file_doc&fileTime=20180216",
							P_NAME: "大雾黄色预警信号发布单",
							P_TIME: "2018-02-16 07:45:00",
							P_USER: "遂宁市气象台",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BFSN_20180216074500_20180006.pdf&fileType=ews_file_pdf&fileTime=20180216"
						},
						{
							ISSUE: "2018年第0006期",
							DESCRIPTION: "蓬溪县发布大雾黄色预警信号",
							FILE_DOC: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXPE_20180216074100_20180006.docx&fileType=ews_file_doc&fileTime=20180216",
							P_NAME: "大雾黄色预警信号发布单",
							P_TIME: "2018-02-16 07:41:00",
							P_USER: "蓬溪县气象局",
							FILE_PDF: "http://10.200.195.28:8088/sndm/api/ThreeLevelMspAction/downloadMsp?fileName=WARN_DW_YE_FB_BXPE_20180216074100_20180006.pdf&fileType=ews_file_pdf&fileTime=20180216"
						}
					];
					if(data.length > 0 && isShowLayer) {
						tableData = [];
						var layerList = {},
							sameCoordsList = {};
						for(var i = 0; i < data.length; i++) {
							var description = data[i]["DESCRIPTION"];
							var sameCoords = data[i]["P_USER"];
							for(var j = 0; j < productClass.type.length; j++) {
								if(description.match(productClass.type[j]["NAME"])) {
									layerList[productClass.type[j]["NAME"]] = layerList[productClass.type[j]["NAME"]] || [];
									layerList[productClass.type[j]["NAME"]].push(data[i]);
								}
							}
							sameCoordsList[data[i]["P_USER"]] = sameCoordsList[data[i]["P_USER"]] || [];
							sameCoordsList[data[i]["P_USER"]].push(data[i]["P_USER"]);
						}
						//表格与地图图层关联----加载图层

						for(var i in layerList) {
							var layerJSON = predictObj.createLayerJSON(layerList[i], sameCoordsList, tableData, predictObj);
							var pFeaLayer = predictObj.createFeatureLayer(layerJSON, ["gid"], "gid", {
								layerInfo: {
									LayerId: i + layerNameSuffix,
									LayerName: i + layerNameSuffix,
									Labeled: false,
									Lods: [],
									Transparency: 1
								},
								geometryType: "esriGeometryPoint",
								levelClass: productClass.level,
								typeClass: productClass.type
							}, predictObj);
							pFeaLayer.on("mouse-over", function(evt) {
								var g = evt.graphic;
								predictObj.map.infoWindow.setContent(g.getContent());
								predictObj.map.infoWindow.setTitle(g.getTitle());
								//predictObj.map.infoWindow.show(evt.screenPoint, predictObj.map.getInfoWindowAnchor(evt.screenPoint));
								predictObj.map.infoWindow.show(g.geometry, predictObj.map.getInfoWindowAnchor(g.geometry));
							});
							pFeaLayer.on("mouse-out", function(evt) {
								predictObj.map.infoWindow.hide();
							});
							pFeaLayer.on("click", function(evt) {
								var g = evt.graphic;
								$('#myModal').on('show.bs.modal', function() { //61.157.118.158:8088
									predictObj.showPdf($('#preview-msg')[0], g.attributes.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
								});
								$('#myModal').modal('show');
							});
							predictObj.map.addLayer(pFeaLayer);
						}
					} else if(data.length > 0 && !isShowLayer) {
						tableData = data;
					}

					//2.加载预警信号列表
//					var $table = $("#" + $tableId);
//					var child = $table.children();
//					if(child.length > 0) {
//						child.remove();
//					}
					predictObj.layui_table.render({
						//id: this.signalTableId,
						elem: '#' + this.signalTableId,
						cols: [
							[{
									field: 'DESCRIPTION',
									title: '产品标题',
									sort: true
								},
								{
									field: 'P_TIME',
									title: '发布时间',
									sort: true
								},
								{
									field: 'P_USER',
									title: '发布单位',
									sort: true
								},
								{
									field: 'FILE_DOC',
									visible: false
								},
								{
									field: 'FILE_PDF',
									visible: false
								},
								{
									field: 'X',
									visible: false
								},
								{
									field: 'Y',
									visible: false
								}
							]
						],
						data: tableData,
						//skin: 'line', //表格风格
						even: true,
						page: true, //是否显示分页
						limits: [5, 7, 10],
						limit: 5, //每页默认显示的数量
//						done:function(res,curr,count){
//							$("[data-field='X']").css('display','none');
//							$("[data-field='Y']").css('display','none');						
//						}					
					});
					//predictObj.layui_table.reload(predictObj.signalTableId, tableData);
					//                  $table.bootstrapTable({
					//                      data: tableData,
					//                      height:'500px',
					//                      striped: true,                       //是否显示行间隔色
					//                      pagination: true,                    //是否显示分页（*）                                
					//                      search: true,                        //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大                                                                                  
					//                      pageSize: 5,                         //每页的记录行数（*）
					//                      //pageList: [5, 25, 50, 100],        //可供选择的每页的行数（*）
					//                      sidePagination: "client",
					//                      //showColumns: true,                 //是否显示所有的列
					//                      //showRefresh: true,                 //是否显示刷新按钮
					//                      //showToggle: true,                  //是否显示详细视图和列表视图的切换按钮
					//                      //cardView: false,                   //是否显示详细视图
					//                      //detailView: false,                 //是否显示父子表                                
					//                      locale: "zh-CN",                     //默认英文，设置如下就是显示中文                                
					//                      columns: [{
					//                          field: 'DESCRIPTION',
					//                          title: '产品标题',
					//                          sortable: true,
					//                      }, {
					//                          field: 'P_TIME',
					//                          title: '发布时间',
					//                          sortable: true,
					//                      },
					//                      {
					//                          field: 'P_USER',
					//                          title: '发布单位',
					//                          sortable: true,
					//                      },
					//                      {
					//                          field: 'FILE_DOC',
					//                          visible: false
					//                      },
					//                      {
					//                          field: 'FILE_PDF',
					//                          visible: false
					//                      },
					//                      {
					//                          field: 'X',
					//                          visible: false
					//                      },
					//                      {
					//                          field: 'Y',
					//                          visible: false
					//                      }],
					//                      rowStyle: function (row, index) {
					//                          //这里有5个取值代表5中颜色['active', 'success', 'info', 'warning', 'danger'];
					//                          var strclass = "active";
					//                          return { classes: strclass }
					//                      },
					//                      //uniqueId: "usrId",
					//                      clickToSelect: true,                 //是否启用点击选中行
					//                      maintainSelected: true,           //设置为 true 在点击分页按钮或搜索按钮时，将记住checkbox的选择项
					//                      //responseHandler: responseHandler, //在渲染页面数据之前执行的方法，此配置很重要!!!!!!!  
					//                  });
					//                  //绑定选中事件、取消事件、全部选中、全部取消  
					//                  $table.on('click-row.bs.table', function (e, rows) {
					//                      predictObj.map.centerAndZoom(new esri.geometry.Point(rows.X, rows.Y, 4326), 13);  
					//                      $('#myModal').on('show.bs.modal', function () {//61.157.118.158:8088
					//                          predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
					//                      });
					//                      $('#myModal').modal('show');
					//                  });
					//              
				},
				error: function() {}
			});
		},

		//获取灾害预警列表并初始化表格
		createWarningTable: function(url, predictObj, options) {
			$.ajax({
				url: url,
				type: 'GET',
				success: function(data) {
					options = options || {};
					var $tableId = options.tableId || predictObj.warningTableId;
					var productClass = predictObj.warningClass;

					var tableData = data; //warningData;
					//2.加载产品列表
//					var $table = $("#" + $tableId);
//					var child = $table.children();
//					if(child.length > 0) {
//						child.remove();
//					}
					//                  $table.bootstrapTable({
					//                      data: tableData,
					//                      height:'500px',
					//                      striped: true,                       //是否显示行间隔色
					//                      pagination: true,                    //是否显示分页（*）                                
					//                      search: true,                        //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大        
					//                      pageSize: 5,                         //每页的记录行数（*）
					//                      //pageList: [5, 25, 50, 100],        //可供选择的每页的行数（*）
					//                      sidePagination: "client",
					//                      //showColumns: true,                 //是否显示所有的列
					//                      //showRefresh: true,                 //是否显示刷新按钮
					//                      //showToggle: true,                  //是否显示详细视图和列表视图的切换按钮
					//                      //cardView: false,                   //是否显示详细视图
					//                      //detailView: false,                 //是否显示父子表                                
					//                      locale: "zh-CN",                     //默认英文，设置如下就是显示中文                                
					//                      columns: [{
					//                          field: 'DESCRIPTION',
					//                          title: '产品标题',
					//                          sortable: true,
					//                      }, {
					//                          field: 'P_TIME',
					//                          title: '发布时间',
					//                          sortable: true,
					//                      },
					//                      {
					//                          field: 'P_USER',
					//                          title: '发布单位',
					//                          sortable: true,
					//                      },
					//                      {
					//                          field: 'FILE_DOC',
					//                          visible: false
					//                      },
					//                      {
					//                          field: 'FILE_PDF',
					//                          visible: false
					//                      }],
					//                      rowStyle: function (row, index) {
					//                          //这里有5个取值代表5中颜色['active', 'success', 'info', 'warning', 'danger'];
					//                          var strclass = "active";
					//                          return { classes: strclass }
					//                      },
					//                      //uniqueId: "usrId",
					//                      clickToSelect: true,                 //是否启用点击选中行
					//                      maintainSelected: true,           //设置为 true 在点击分页按钮或搜索按钮时，将记住checkbox的选择项
					//                      //responseHandler: responseHandler, //在渲染页面数据之前执行的方法，此配置很重要!!!!!!!  
					//                  });
					//                  //绑定选中事件、取消事件、全部选中、全部取消  
					//                  $table.on('click-row.bs.table', function (e, rows) { 
					//                      $('#myModal').on('show.bs.modal', function () {//61.157.118.158:8088
					//                          predictObj.showPdf($('#preview-msg')[0], rows.FILE_PDF.replace("10.200.195.28:8088", "61.157.118.158:8088"));
					//                      });
					//                      $('#myModal').modal('show');
					//                  });
					//              
				},
				error: function() {}
			});
		},

		//构造GeoJSON
		createLayerJSON: function(records, sameCoordsList, tableData, predictObj) {
			var geojson = {},
				features = [],
				feature, geometry, points;
			geojson.type = "FeatureCollection";
			geojson.features = features;

			for(var i = 0; i < records.length; i++) {
				feature = {};
				feature.type = 'Feature';
				geometry = feature.geometry = {};
				geometry.type = "Point";
				var coords = [];
				var station = predictObj.station;
				for(var j = 0; j < station.length; j++) {
					if(records[i]["P_USER"] === station[j].NAME) {
						var sameCrdCount = sameCoordsList[records[i]["P_USER"]].length;
						var xMin = station[j].X - 0.00001042 * 3000 * sameCrdCount / 2; //0.00001042表示东西方向一米的距离
						var xMax = station[j].X + 0.00001042 * 3000 * sameCrdCount / 2;
						var yMin = station[j].Y - 0.00000899 * 3000 * sameCrdCount / 2; //0.00000899表示南北方向一米的距离
						var yMax = station[j].Y + 0.00000899 * 3000 * sameCrdCount / 2;
						coords.push(parseFloat((xMax - xMin) * Math.random() + xMin));
						coords.push(parseFloat((yMax - yMin) * Math.random() + yMin));
					}
				}

				geometry.coordinates = coords;
				if("coordinates" in feature.geometry) features.push(feature);
				var displayRecords = records[i];
				displayRecords["gid"] = displayRecords["gid"] || i;
				displayRecords["X"] = displayRecords["X"] || coords[0];
				displayRecords["Y"] = displayRecords["Y"] || coords[1];
				feature.properties = displayRecords;
				tableData.push(displayRecords);
			};
			return geojson;
		},

		createFeatureLayer: function(layerJson, fieldList, oid, options, predictObj) {
			//id, name, geometryType, 
			var id = options.layerInfo.LayerId,
				name = options.layerInfo.LayerName,
				geometryType = options.geometryType,
				layerInfo = options.layerInfo,
				hasZM = false,
				levelClass = options.levelClass,
				typeClass = options.typeClass;
			var symbol;
			//1.定义展示字段
			var fields = [],
				field;
			for(var i = 0; i < fieldList.length; i++) {
				if(fieldList[i] === oid) {
					field = {
						"name": oid,
						"alias": oid,
						"type": "esriFieldTypeOID",
						"length": "50",
						"nullable": "false",
						"editable": "false"
					}
				} else {
					field = {
						"name": fieldList[i],
						"alias": fieldList[i],
						"type": "esriFieldTypeString",
						"length": "80",
						"nullable": "true",
						"editable": "false"
					}
				}
				fields.push(field);
			}
			//2.定义空图层基本信息            
			var layerDefinition = {
				"geometryType": geometryType,
				"objectIdField": oid,
				"fields": fields,
				"drawingInfo": {
					"renderer": {
						"type": "simple",
						"symbol": symbol
					}
				}
			}
			var featureCollection = {
				layerDefinition: layerDefinition,
				featureSet: null
			};
			var popupTemplate = new esri.dijit.PopupTemplate({
				title: "{DESCRIPTION}",
				description: "发布单位：{P_USER}</br>发布时间：{P_TIME}</br>发布期号：{ISSUE}</br>"
			});
			var featureLayer = new esri.layers.FeatureLayer(featureCollection, {
				id: id,
				outFields: fieldList,
				infoTemplate: popupTemplate,
				showLabels: true
			});

			//3.添加要素
			if(layerJson.features.length <= 0) {
				return;
			}
			var features = [],
				isClassified = true,
				symbol;
			for(var j = 0; j < layerJson.features.length; j++) {
				var geometry, value = null,
					feature = layerJson.features[j];
				geometry = predictObj.geojson2graphic(feature.geometry);
				var description = feature.properties["DESCRIPTION"];
				var pictureName = "";
				for(var m in typeClass) {
					if(description.match(typeClass[m]["NAME"])) {
						pictureName += typeClass[m]["P_ID"];
						break;
					}
				}
				for(var n in levelClass) {
					if(description.match(levelClass[n]["NAME"])) {
						pictureName += levelClass[n]["P_ID"].substring(levelClass[n]["P_ID"].length - 3);
						if(!predictObj.validateImage("../js/prediction/img/prediction/" + pictureName + ".jpg")) {
							pictureName = "WARN_QT";
						}
						symbol = predictObj.Symbology.pictureMarkerSymbol({
							Url: "../js/prediction/img/prediction/" + pictureName + ".jpg",
							Size: 32
						})
						break;
					}
				}
				var graphic = new esri.Graphic(geometry, symbol, layerJson.features[j].properties, featureLayer.infoTemplate);
				features.push(graphic);
				featureLayer.add(graphic);
			}
			featureLayer._featureSet = {
				"features": features,
				"geometryType": geometryType
			}
			featureLayer._featureLayer = features;
			featureLayer.graphics = features;
			featureLayer.opacity = layerInfo.Transparency;
			if(layerInfo.Lods.length > 0) {
				featureLayer.setScaleRange(Math.max.apply(Math, layerInfo.Lods), Math.min.apply(Math, layerInfo.Lods));
			}
			if(hasZM) {
				featureLayer.hasZ = true;
				featureLayer.hasM = true;
			}
			return featureLayer;
		},

		geojson2graphic: function(geojson, options) {
			var spatialReference;

			options = options || {
				sr: 4326
			};
			var idAttribute = options.idAttribute || "gid" || "OBJECTID";

			if(options.sr) {
				spatialReference = {
					wkid: options.sr
				};
			} else {
				spatialReference = {
					wkid: 4326
				};
			}

			var result = {};
			var i;
			switch(geojson.type) {
				case "Point":
					result.x = geojson.coordinates[0];
					result.y = geojson.coordinates[1];
					if(geojson.coordinates[2]) {
						result.z = geojson.coordinates[2];
					}
					if(geojson.coordinates[3]) {
						result.m = geojson.coordinates[3];
					}
					result.spatialReference = spatialReference;
					result = new esri.geometry.Point(result);
					break;
				case "MultiPoint":
					result.points = geojson.coordinates.slice(0);
					result.spatialReference = spatialReference;
					result = new esri.geometry.Multipoint(result);
					break;
				case "LineString":
					result.paths = [geojson.coordinates.slice(0)];
					result.spatialReference = spatialReference;
					result = new esri.geometry.Polyline(result);
					break;
				case "MultiLineString":
					try {
						result.paths = geojson.coordinates.slice(0);
						result.spatialReference = spatialReference;
						result = new esri.geometry.Polyline(result);
					} catch(e) {
						var aaa = e;
					}
					break;
				case "Polygon":
					result.rings = orientRings(geojson.coordinates.slice(0));
					result.spatialReference = spatialReference;
					result = new esri.geometry.Polygon(result);
					break;
				case "MultiPolygon":
					result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0));
					result.spatialReference = spatialReference;
					result = new esri.geometry.Polygon(result);
					break;
				case "Feature":
					if(geojson.geometry) {
						result.geometry = predictObj.geojson2graphic(geojson.geometry, options);
					}
					result.attributes = (geojson.properties) ? predictObj.clone(geojson.properties) : {};
					result.attributes[idAttribute] = geojson.id;
					break;
				case "FeatureCollection":
					result = [];
					for(i = 0; i < geojson.features.length; i++) {
						result.push(predictObj.geojson2graphic(geojson.features[i], options));
					}
					break;
				case "GeometryCollection":
					result = [];
					for(i = 0; i < geojson.geometries.length; i++) {
						result.push(predictObj.geojson2graphic(geojson.geometries[i], options));
					}
					break;
			}

			return result;
		},

		clone: function(obj) {
			var target = {};
			for(var i in obj) {
				if(obj.hasOwnProperty(i)) {
					target[i] = obj[i];
				}
			}
			return target;
		},

		//PDF文件预览
		showPdf: function(container, url) {
			container.style.display = "block";
			PDFJS.workerSrc = '../js/prediction/dep/pdf-worker.js';
			PDFJS.getDocument(url).then(function getPdfHelloWorld(pdf) {
				//
				// Fetch the first page
				//                    
				pdf.getPage(1).then(function getPageHelloWorld(page) {
					var scale = 1.5;
					var viewport = page.getViewport(scale);

					//
					// Prepare canvas using PDF page dimensions
					//
					var canvas = document.getElementById('the-canvas');
					canvas.remove();
					$("#pop").append('<canvas id="the-canvas"></canvas>');
					canvas = document.getElementById('the-canvas');
					var context = canvas.getContext('2d');

					canvas.height = viewport.height;
					canvas.width = viewport.width;

					// Render PDF page into canvas context
					//
					var renderContext = {
						canvasContext: context,
						viewport: viewport
					};
					page.render(renderContext);
				});
			});
		},

		//判断图片是否存在
		validateImage: function(url) {
			var xmlHttp;
			if(window.ActiveXObject) {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} else if(window.XMLHttpRequest) {
				xmlHttp = new XMLHttpRequest();
			}
			xmlHttp.open("Get", url, false);
			xmlHttp.send();
			if(xmlHttp.status == 404)
				return false;
			else
				return true;
		},

		Symbology: {
			pointSymbol: function(options) {
				var pSymbol = new esri.symbol.SimpleMarkerSymbol();
				pSymbol.setPath(options.iconUrl);
				pSymbol.setColor(options.iconColor);
				pSymbol.setSize(options.iconSize);
				return pSymbol;
			},

			polylineSymbol: function(options) {
				var pSymbol = new esri.symbol.SimpleLineSymbol();
				var style = options.iconUrl.split(' ')[0]
				switch(style) {
					case "STYLE_SOLID":
						pSymbol.setStyle(esri.symbol.SimpleLineSymbol.STYLE_SOLID);
						break;
					case "STYLE_SHORTDOT":
						pSymbol.setStyle(esri.symbol.SimpleLineSymbol.STYLE_SHORTDOT);
						break;
					case "STYLE_LONGDASH":
						pSymbol.setStyle(esri.symbol.SimpleLineSymbol.STYLE_LONGDASH);
						break;
					case "STYLE_LONGDASHDOT":
						pSymbol.setStyle(esri.symbol.SimpleLineSymbol.STYLE_LONGDASHDOT);
						break;
				}
				pSymbol.setColor(options.iconColor);
				pSymbol.setWidth(options.iconSize);
				return pSymbol;
			},

			polygonSymbol: function(options) {
				var pSymbol = new esri.symbol.SimpleFillSymbol();
				var colors = options.iconColor.split(';');
				var style = options.iconUrl,
					outlineStyle;
				switch(style) {
					case "STYLE_SOLID":
						outlineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
						break;
					case "STYLE_SHORTDOT":
						outlineStyle = esri.symbol.SimpleLineSymbol.STYLE_SHORTDOT;
						break;
					case "STYLE_LONGDASH":
						pSymbol.setStyle(esri.symbol.SimpleLineSymbol.STYLE_LONGDASH);
						break;
					case "STYLE_LONGDASHDOT":
						outlineStyle = esri.symbol.SimpleLineSymbol.STYLE_LONGDASHDOT;
						break;
					default:
						outlineStyle = null;
						break;
				}
				pSymbol.setStyle(esri.symbol.SimpleFillSymbol.STYLE_SOLID);
				if(outlineStyle !== null) {
					pSymbol.setOutline(new esri.symbol.SimpleLineSymbol().setStyle(outlineStyle).setWidth(options.iconSize).setColor(new esri.Color(colors[1])));
				} else {
					pSymbol.setOutline(new esri.symbol.SimpleLineSymbol().setWidth(0));
				}
				pSymbol.setColor(colors[0]);
				return pSymbol;
			},

			pictureMarkerSymbol: function(options) {
				var pSymbol = new esri.symbol.PictureMarkerSymbol({
					"url": options.Url,
					"height": options.Size,
					"width": options.Size,
					"type": "esriPMS",
					"angle": 0,
				});
				return pSymbol;
			},

			rendererPoint: function(value, drawInfo, isClassified) {
				var pSymbol;
				if(isClassified) {
					for(var i = 0; i < drawInfo.length; i++) {
						if(value === drawInfo[i].value) {
							if(drawInfo[i].iconUrl.indexOf("img") > -1) {
								var url = window.location.origin + drawInfo[i].iconUrl;
								pSymbol = predictObj.Symbology.pictureMarkerSymbol({
									Url: url,
									Size: drawInfo[i].iconSize
								});
							} else {
								pSymbol = predictObj.Symbology.pointSymbol({
									iconColor: drawInfo[i].iconColor,
									iconUrl: drawInfo[i].iconUrl,
									iconSize: drawInfo[i].iconSize
								});
							}
						}
					}
				} else {
					if(drawInfo[0].iconUrl.indexOf("img") > -1) {
						url = window.location.origin + drawInfo[0].iconUrl;
						pSymbol = predictObj.Symbology.pictureMarkerSymbol({
							Url: url,
							Size: drawInfo[0].iconSize
						});
					} else {
						pSymbol = predictObj.Symbology.pointSymbol({
							iconColor: drawInfo[0].iconColor,
							iconUrl: drawInfo[0].iconUrl,
							iconSize: drawInfo[0].iconSize
						});
					}
				}
				return pSymbol;
			},

			rendererLine: function(value, drawInfo, isClassified) {
				var pSymbol;
				if(isClassified) {
					for(var i = 0; i < drawInfo.length; i++) {
						if(value === drawInfo[i].value) {
							pSymbol = predictObj.Symbology.polylineSymbol({
								iconColor: drawInfo[i].iconColor,
								iconUrl: drawInfo[i].iconUrl,
								iconSize: drawInfo[i].iconSize
							});
						}
					}
				} else {
					pSymbol = predictObj.Symbology.polylineSymbol({
						iconColor: drawInfo[0].iconColor,
						iconUrl: drawInfo[0].iconUrl,
						iconSize: drawInfo[0].iconSize
					});
				}
				return pSymbol;
			},

			rendererPolygon: function(value, drawInfo, isClassified) {
				var pSymbol; // = new esri.symbol.SimpleFillSymbol();
				if(isClassified) {
					for(var i = 0; i < drawInfo.length; i++) {
						if(value === drawInfo[i].value) {
							pSymbol = predictObj.Symbology.polygonSymbol({
								iconColor: drawInfo[i].iconColor,
								iconUrl: drawInfo[i].iconUrl,
								iconSize: drawInfo[i].iconSize
							});
						}
					}
				} else {
					pSymbol = predictObj.Symbology.polygonSymbol({
						iconColor: drawInfo[0].iconColor,
						iconUrl: drawInfo[0].iconUrl,
						iconSize: drawInfo[0].iconSize
					});
				}
				return pSymbol;
			},
		},
		//加载css文件
		loadStyle: function(urlList, callback) {
			for(var i in urlList) {
				var url = urlList[i];
				var link = document.createElement('link');
				link.type = 'text/css';
				link.rel = 'stylesheet';
				link.href = url;
				var head = document.getElementsByTagName('head')[0];
				head.appendChild(link);
			}
			callback();
		},

	});

	function padLeft() {
		String.prototype.padLeft =
			Number.prototype.padLeft = function(total, pad) {
				return(Array(total).join(pad || 0) + this).slice(-total);
			}
	}

	function formateData(wkt) {
		var feature = (new ol.format.WKT()).readFeature(wkt);
		var geojson = (new ol.format.GeoJSON()).writeFeature(feature);
		var polygon = new esri.geometry.Polygon(JSON.parse(geojson).geometry.coordinates);
		return polygon;
	}

});